
#ifndef OPERON_ABSTRACTDB_HEADER
#define	OPERON_ABSTRACTDB_HEADER

#include <stdio.h>
#include "berkeley/berkeley.h"


#ifdef	__cplusplus
extern "C" {
#endif

//forward declaration of operon
struct Operon_t;

/**
 * define an abstract database (<=>a berkeleyDB) in
 * the operon environement
 *
 */
typedef    struct OperonDB_t
    {
    /** link to my operon */
	struct Operon_t* operon;
    /** the berkeleyDB database */
    DB       *database;
    /** return a unique identifier of this database */
    int (*getDababaseId)(void);
    /** returns a short name about this database */
    const char* (*getName) (void);
    /** returns a longer description about this database */
    const char* (*getDescripton) (OutputFormat format);
    /** open this database */
    int (*open)(void);
    /** close this database */
    int (*close)(void);
    } OperonDB,* OperonDBPtr;

/**
 * initialize a DB. This function should be called by the derived classes
 * @param ptr the pointer to initialize
 * @param operon the operon context
 * @return a AbstractDBPtr initialized or NULL if there was a problem
 */
extern OperonDBPtr AbstractDBInit(OperonDBPtr ptr, OperonPtr operon);

/**
 * Free the resource allocated by the db (closes the db)
 * @param ptr the pointer to free
 */
extern void AbstractDBDelete(OperonDBPtr ptr);


#ifdef	__cplusplus
}
#endif

#endif	/* OPERON_ABSTRACTDB_HEADER */
